package com.kid.keep.mapper;

import com.kid.keep.bo.ChildCheckItemBO;
import com.kid.keep.dto.*;
import com.kid.keep.po.*;
import com.kid.keep.request.AddCheckItemResultRequest;
import com.kid.keep.vo.*;
import com.honeybee.cloud.framework.common.mapper.BaseCovertMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.Date;
import java.util.List;

/**
 * @Description 转换mapper
 * @Author JOHN
 * @Create 2020-01-02
 * @Since 1.0.0
 */
@Mapper(componentModel = "spring")
public interface ICheckItemCovertMapper extends BaseCovertMapper {


    /**
     * po to  po
     *
     * @param reportId
     * @param childId
     * @param checkItem
     * @param id
     * @return
     */
    @Mappings({
            @Mapping(target = "itemId", source = "checkItem.id"),
            @Mapping(target = "id", source = "id"),
            @Mapping(target = "updateDate", ignore = true)
    })
    ChildCheckItem toPO(CheckItem checkItem, Long reportId, Long childId, Long id);


    /**
     * po to  po
     *
     * @param child
     * @param status
     * @param id
     * @param updateDate
     * @param updateDate
     * @param orderNumber
     * @param creatorId
     * @return
     */
    @Mappings({
            @Mapping(target = "childName", source = "child.name"),
            @Mapping(target = "childId", source = "child.id"),
            @Mapping(target = "id", source = "id"),
            @Mapping(target = "age", source = "child.birthday", qualifiedByName = "age"),
            @Mapping(target = "updateDate", source = "updateDate"),
    })
    CheckItemReport toPO(Long id, Child child, Integer status, Date createDate, Date updateDate, Long creatorId);


    /**
     * po to  dto
     *
     * @param checkItemReport
     * @return
     */

    CheckItemReportDTO toDTO(CheckItemReport checkItemReport);

    /**
     * po to  dto
     */

    AddChildCheckItemResultDTO  toDTO(ChildCheckItem childCheckItem);

    /**
     * dto to  vo
     *
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    AddChildCheckItemResultVO toVO(AddChildCheckItemResultDTO childCheckItemResultDTO);

    /**
     * bo to  dto
     *
     * @param childCheckItem
     * @param nextItem
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "childCheckItem.id"),
            @Mapping(target = "grade", source = "childCheckItem.grade"),
            @Mapping(target = "itemName", source = "childCheckItem.itemName"),
            @Mapping(target = "result", source = "childCheckItem.result"),
            @Mapping(target = "scope", source = "childCheckItem.scope"),
            @Mapping(target = "updateDate", source = "childCheckItem.updateDate"),
            @Mapping(target = "unit", source = "childCheckItem.unit"),
            @Mapping(target = "commentContent", source = "childCheckItem.commentContent"),
            @Mapping(target = "nextItem", source = "nextItem"),
    })
    ChildCheckItemResultDetailDTO toDTO(ChildCheckItemBO childCheckItem,ChildCheckItemBO nextItem);
    /**
     * dto to  response
     *
     * @param childCheckItemDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString"),
    })
    ChildCheckItemResultDetailVO toVO(ChildCheckItemResultDetailDTO childCheckItemDTO);


    /**
     * request to  dto
     *
     * @param resultRequest
     * @param itemId
     * @param reportId
     * @return
     */
    AddCheckItemResultDTO toDTO(AddCheckItemResultRequest resultRequest, Long itemId, Long reportId);


    /**
     * po to  dto
     *
     * @param childCheckItem
     * @return
     */
    ChildCheckItemDTO toDTO(ChildCheckItemBO childCheckItem);


    /**
     * bo to  dto
     *
     * @param childCheckItems
     * @return
     */
    List<ChildCheckItemDTO> toDTO(List<ChildCheckItemBO> childCheckItems);

    /**
     * dto to  po
     *
     * @param id
     * @param result
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id"),
    })
    ChildCheckItem toPO(Long id, Integer result, CheckItemStandard checkItemStandard, Date updateDate);

    /**
     * dto to  response
     *
     * @param childCheckItemDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    AddCheckItemResultVO toVO(ChildCheckItemDTO childCheckItemDTO);

    /**
     * dto to  vo
     *
     * @param itemDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    ChildCheckItemVO toCheckItemVO(ChildCheckItemDTO itemDTO);
    /**
     * dto to  response
     *
     * @param checkItemReportDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    AddCheckItemResultVO toVO(CheckItemReportDTO checkItemReportDTO);


    /**
     * dto to  po
     *
     * @param id
     * @param grade
     * @param scope
     * @param updateDate
     * @param status
     * @param commentId
     * @return
     */
    CheckItemReport toPO(Long id, Integer grade, Integer scope,Long commentId, Date updateDate, Integer status,int orderNumber);

    /**
     * dto to  response
     *
     * @param checkItemReportDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id", source = "id", qualifiedByName = "toString")
    })
    CheckItemReportVO toReportVO(CheckItemReportDTO checkItemReportDTO);


    /**
     * dto to  vo
     *
     * @param childCheckItemDTOS
     * @return
     */
    List<ChildCheckItemVO> toVO(List<ChildCheckItemDTO> childCheckItemDTOS);

}
